home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 4352 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.5 KB

  1. Path: nntp.teleport.com!sschaem
  2. From: sschaem@teleport.com (Stephan Schaem)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: Integer Sine tables?
  5. Date: 27 Feb 1996 20:36:42 GMT
  6. Organization: Teleport - Portland's Public Access (503) 220-1016
  7. Message-ID: <4gvq0q$qqd@maureen.teleport.com>
  8. References: <4glqbd$4ab@nnrp1.news.primenet.com> <4gpbi1$3i5@maureen.teleport.com> <1996Feb26.162410.27523@imada.ou.dk>
  9. NNTP-Posting-Host: linda.teleport.com
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Bjorn Reese (breese@imada.ou.dk) wrote:
  13. : Stephan Schaem (sschaem@teleport.com) wrote:
  14. : >  You can alway open the math.library fpu or not... Thats the easyest.
  15. : >  I dont know the incremental methode using integer math, anyone?
  16.  
  17. : Hey, wait a second. Didn't I send you the C source for the Cordic
  18. : method once, which you translated into asm? ;)
  19.  
  20.  Did I? my god yea, I totaly forgot :) Well, I will post it then ...
  21.  
  22.  But this is not what I had in mind when I was saying incremental
  23.  function to build a sin table... this function will return the actual
  24.  sin value of any number you feed it.
  25.  The sad thing is I only used it to build a small sin/cos table for my
  26.  matrix rotation :)
  27.  
  28.  speaking of math... any idea how to find an aproximation of the curve
  29.  y = 1/(1/x) = x^2 using an incremental methode like: y = x+a , a+=b ?
  30.  (its just that its in my head right at this moment and I'm blank :)
  31.  
  32.  Stephan
  33.  
  34. ;------------------------------------------------------------------------------
  35. ;
  36. ; INPUT:    d0.l = Angle in radian
  37. ;
  38. ; OUTPUT:    d0.l = sin(A) 29bit precision
  39. ;
  40. ; NOTE:        The CORDIC algorithms with the setting for sin hardcoded.
  41. ;        This function trash d2-d6.
  42. ;
  43. fractionBits    = 14
  44. HalfPi        = 843314856
  45.  
  46. Sin:
  47.     move.l    #$136e9db3>>(29-fractionBits),d4    ;X
  48.     move.l    d0,d1            ;Z
  49.     moveq    #0,d0            ;Y
  50.     moveq    #0,d3            ;i
  51.     lea    (.atan,pc),a0
  52.     moveq    #fractionBits-1,d2
  53. .Loop0    move.l    d4,d5
  54.     move.l    d0,d6            ;
  55.     asr.l    d3,d5            ;x = X>>i
  56.     asr.l    d3,d6            ;y = Y>>i
  57.     addq.l    #1,d3            ;i++
  58.     sub.l    d6,d4            ;X-=y
  59.     add.l    d5,d0            ;Y+=x
  60.     sub.l    (a0)+,d1        ;Z-=atan[i]
  61.     blt.b    1$
  62. 0$    dbra    d2,.Loop0
  63.     rts
  64. .Loop1    move.l    d4,d5
  65.     move.l    d0,d6
  66.     asr.l    d3,d5            ;x = X>>i
  67.     asr.l    d3,d6            ;y = Y>>i
  68.     addq.l    #1,d3            ;i++
  69.     add.l    d6,d4            ;X+=y
  70.     sub.l    d5,d0            ;Y-=x
  71.     add.l    (a0)+,d1        ;Z+=atan[i]
  72.     bge.b    0$
  73. 1$    dbra    d2,.Loop1
  74.     rts
  75. .atan    dc.l $1921fb54,$0ed63382,$07d6dd7e,$03fab753,$01ff55bb,$00ffeaad,$007ffd55,$003fffaa
  76.     dc.l $001ffff5,$000ffffe,$0007ffff,$00040000,$00020000,$00010000,$00008000,$00004000
  77.     dc.l $00002000,$00001000,$00000800,$00000400,$00000200,$00000100,$00000080,$00000040
  78.     dc.l $00000020,$00000010,$00000008,$00000004,$00000002,$00000001
  79.  
  80.